<?php

/* 商品分类 gcategory */
class Ogps_packageModel extends BaseModel
{
    var $table  = 'ogps_package';
    var $prikey = 'package_id';
    var $_name  = 'ogps_package';
    var $_relation  = array(
      
//        // 一个包下边可以有多个物品
//        'has_goods' => array(
//            'model'         => 'ogps_goods',
//            'type'          => HAS_MANY,
//            'foreign_key'   => 'package_id',
//            'dependent'     => true
//        ),
       
    );

    var $_autov = array(
        'package_name' => array(
            'required'  => true,
            'filter'    => 'trim',
        ),
        'package_budget' => array(
            'required'  => true,
            'filter'    => 'floatval',
        ),
        'bid_id' => array(
            'required'  => true,
            'filter'    => 'intval',
        ),
    );
    
    const BID_ID_DEFAULT=-1;
    
    public function add($data, $compatible = false) {
        
        $conditions = "package_name = '" . $data['package_name'] . "'";
        $conditions .= " AND offerproject_id = '" . $data['offerproject_id'] . "'";
        if(count($this->find(array('conditions' => $conditions))) > 0){
            $this->_error('package_is_unique');
        }
        
        return parent::add($data, $compatible);
    }
}


?>